package owg.util.opengl;

import com.jogamp.opengl.GL;

import owg.util.opengl.models.HPRF;
import owg.util.opengl.models.VertexF;

/**
 * This class defines static methods for generating various mathematically defined models.
 */
public class PrimitiveFactory {
	/**Generates a model of an axis aligned rectangle filling the indicated area on the X/Y plane.<br/>
	 * The minimum texture coordinates will always be 0, but the maximum texture coordinates may be set to the indicated values.*/
	public static<GLT extends GL> HPRF genSquare(EGL<GLT> glUtil, float x0, float y0, float x1, float y1, float textureHRepeat, float textureVRepeat)
	{
		HPRF o = glUtil.genModel("Square", false, false, GL.GL_TRIANGLE_STRIP, 
				2, true, 0, 2, 0);
		
		o.addVertex(new VertexF(
				new float[]{x0,y1},
				new float[]{0,0,1},
				null,
				new float[]{0,textureVRepeat},
				null
				));
		o.addVertex(new VertexF(
				new float[]{x0,y0},
				new float[]{0,0,1},
				null,
				new float[]{0,0},
				null
				));
		o.addVertex(new VertexF(
				new float[]{x1,y1},
				new float[]{0,0,1},
				null,
				new float[]{textureHRepeat,textureVRepeat},
				null
				));
		o.addVertex(new VertexF(
				new float[]{x1,y0},
				new float[]{0,0,1},
				null,
				new float[]{textureHRepeat,0},
				null
				));
		o.quad(false);
		o.end(glUtil);
		return o;
	}
}
